﻿<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<LINK rel="Bookmark" href="/favicon.ico" >
	<LINK rel="Shortcut Icon" href="/favicon.ico" />
	<link type="text/css" rel="stylesheet" href="themes/icon.css"/>
	<link type="text/css" rel="stylesheet" href="themes/bootstrap/easyui.css"/>
	<link type="text/css" rel="stylesheet" href="lib/Hui-iconfont/1.0.1/iconfont.css"/>
	<link type="text/css" rel="stylesheet" href="easyui_css/main.css" />
	<link type="text/css" rel="stylesheet" href="easyui_css/easyui-extends.css"/>
	<link type="text/css" rel="stylesheet" href="css/H-ui.min2.css" />
	<link rel="stylesheet" type="text/css" href="admin/css/iconfont/iconfont.css" />
	<link type="text/css" rel="stylesheet" href="css/mywork.css" />
	<script type="text/javascript" src="easyui_js/jquery-1.7.2.min.js"></script>
	<script type="text/javascript" src="easyui_js/jquery-easyui-1.4.3/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="easyui_js/jquery-easyui-1.4.3/plugins/datagrid-detailview.js"></script>
	<script type="text/javascript" src="easyui_js/jquery-easyui-1.4.3/locale/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="easyui_js/jcommon.js"></script>
	<script type="text/javascript" src="easyui_js/main.js"></script>
	<script type="text/javascript" src="lib/layer/1.9.3/layer.js"></script>
	<script type="text/javascript" src="js/common.js"></script>
	<script type="text/javascript" src="js/formatter.js"></script>
	<title>薪资列表</title>
</head>
<body class="easyui-layout" style="width: 100%; height: 100%;font-family: 微软雅黑,serif">
<div class="breadcrumb">
	<span><i class="Hui-iconfont">&#xe67f;</i> 首页</span>
	<span>&emsp;&gt;&emsp;薪资管理</span>
	<span>&emsp;&gt;&emsp;薪资列表</span>
	<a style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</div>
<div id='tableInfo' style="width: 100%; height: 100%;"></div>
<!--搜索栏内容-->
<div id="search" style="padding:2px 0px 2px 5px;background-color: #F5FAFE;">
	<span>员工：</span><input id="s_user_id" />
	<span>工资单单号：</span><input id="s_no" />
	<span>是否结算：</span><input id="s_balance" />
	<span>开始日期：</span><input id="s_start" />
	<span>结束日期：</span><input id="s_end" />
	<a id="searchBtn" onclick="doSearch()"></a>
	<a id="exportBtn" onclick="doExport()"></a>
</div>
<script type="text/javascript">
	//分页查询请求参数
	var pageParam = {
		pageNo: 1,
		pageSize: Page.getPageSize(),
		sort: null,
		order: "DESC"
	};

	// 准备函数
	$(function () {
		//表格元素初始化
		$('#tableInfo').datagrid({
			height: $(window).outerHeight() - 40,
			pagination: true,
			singleSelect: false,
            fitColumns:true,	//列宽自适应
			columns: [[
				{field: 'ck', checkbox: 'true'},
				{field: 'id', title: '编号', width: 60, align: 'center', sortable: true},
				{field: 'no', title: '工资单号', width: 100, align: 'center', sortable: true},
				{field: 'user_id', title: '员工编号', width: 60, align: 'center'},
				{field: 'user_name', title: '员工姓名', width: 150, align: 'center'},
				{field: 'money', title: '金额', width: 150, align: 'center'},
				{field: 'create_date', title: '创建日期', width: 140, align: 'center', sortable: true,
					formatter: function(value){
						value = dates("Y-m-d H:i:s", value);
						return value;
					}
				},
				{field: 'is_balance', title: '是否结算', width: 120, align: 'center', sortable: true,
					formatter: function (value, row) {
						return value=='1' ? "是":"否";
					}
				},
				{field: 'balance_date', title: '结算日期', width: 140, align: 'center', sortable: true,
					formatter: function(value){
						value = (value==undefined||value=='' ? '':dates("Y-m-d H:i:s", value));
						return value;
					}
				}
			]],
			//表格工具栏元素ID
			toolbar: '#search',
			onSortColumn: function (sort,order) {  //其中sort代表排序列字段名称；order:排序列的顺序（ASC或DESC）
				pageParam.pageNo = 1;
				pageParam.sort = sort;
				pageParam.order = order;
				query(pageParam);
			},
			onSelect: function (rowIndex, rowData) {
				selectedTableRow();
			},
			onUnselect: function (rowIndex, rowData) {
				selectedTableRow();
			},
			onSelectAll: function (rowIndex, rowData) {
				selectedTableRow();
			},
			onUnselectAll: function (rowIndex, rowData) {
				selectedTableRow();
			},
			onLoadSuccess: function (data) {
			}
		});
		var pager = $('#tableInfo').datagrid('getPager');
		pager.pagination({
			total: 0,
			rows: 0,
			pageNumber: pageParam.pageNo,
			pageSize: pageParam.pageSize,
			pageList: [20, pageParam.pageSize, 30],
			onBeforeRefresh : function() {
				$(this).pagination('loading');
			},
			onSelectPage: function(pageNumber, pageSize) {
				pageParam.pageNo = pageNumber;
				pageParam.pageSize = pageSize;
				query(pageParam);
			},
			onChangePageSize: function(pageSize) {
				pageParam.pageSize = pageSize;
//                query(pageParam);
			}
		});
		initSearchForm();
		//获取登录用户信息，展示可查询信息
		$.ajax({
			type: "POST",
			dataType: "json",
			url: "../Manage/getSessionManage",
			async: false,
			success: function(data) {
				if (data.rtnCode == "0000000"){
					if (data.bizData.roleType != "GLB" && data.bizData.roleType != "CWB") {
						$("#s_user_id").combobox("setValue", data.bizData.id);
						$("#s_user_id").combobox("disable");
					}
				}else {
					layer.msg('获取用户信息失败',{icon:6,time:2000});
					$("#tableInfo").datagrid("loaded");
				}
			},
			error : function(err) {
				layer.msg('获取用户信息失败',{icon:6,time:2000});
				$("#tableInfo").datagrid("loaded");
			}
		});
		query(pageParam);
	});

	//查询框元素初始化
	function initSearchForm(){
		$("#fm").form('clear');

		$("#s_user_id").combobox({
			width: 150,
			panelHeight:"auto",
			valueField: 'id',
			textField: 'name',
			editable: false,
			url: "../Manage/getManagesByRole",
			queryParams: {code: "XSB", isAll: false},
			loadFilter: function (data) {
				return data.bizData;
			},
			onChange: function (value) {
			}
		});
		$("#s_balance").combobox({
			width: 150,
			prompt: '',
			panelHeight:"auto",
			valueField: 'value',
			textField: 'text',
			editable: false,
			data: [{value: "-1", text: "全部", selected:true},{value: "0", text: "未结算"},{value: "1", text: "已结算"}]
		});
		$("#s_no").textbox({
			width: 150,
			prompt: '请输入工资单编号'
		});
		$("#s_start").datebox({
			width: 150,
			prompt: '请输入起始日期',
			editable: false
		});
		$("#s_end").datebox({
			width: 150,
			prompt: '请选择截止日期',
			editable: false
		});
		$("#searchBtn").linkbutton({
			plain:"true",
			text: '<i class="Hui-iconfont">&#xe665;</i>查询'
		});
		$("#exportBtn").linkbutton({
//			iconCls: '',
			plain: 'true',
			text: '<i class="Hui-iconfont">&#xe644;</i>导出'
		});
	}
	
	//查询按钮事件
	function doSearch() {
		query(pageParam, true);
	}

	//导出按钮事件
	function doExport() {
		var user_id=$("#s_user_id").combobox("getValue");
		var is_balance=$("#s_balance").combobox("getValue");
		var no=$("#s_no").textbox("getValue");
		var start=$("#s_start").datebox("getValue");
		var end=$("#s_end").datebox("getValue");
		window.location.href= getRootPath() + "/demo/Salary/exportExcel?user_id="+user_id+"&is_balance="+is_balance+
				"&no="+no+"&start="+start+"&end="+end;
	}

	// 分页查询
	function query(pageParam, goHead) {
		pageParam.s_user_id=$("#s_user_id").combobox("getValue");
		pageParam.s_balance=$("#s_balance").combobox("getValue");
		pageParam.s_no=$("#s_no").textbox("getValue");
		pageParam.s_start=$("#s_start").datebox("getValue");
		pageParam.s_end=$("#s_end").datebox("getValue");
        if (goHead != undefined && goHead)
            pageParam.pageNo = 1;
		$("#tableInfo").datagrid("loading");
		$.ajax({
			type: "POST",
			dataType: "json",
			url: "../Salary/getSalaryPage" ,
			data: pageParam,
			success: function(data) {
				if (data.rtnCode == "0000000"){
					$("#tableInfo").datagrid('loadData', data.bizData.rows);
					$("#tableInfo").datagrid("loaded");
					$("#tableInfo").datagrid('getPager').pagination({pageNumber: data.bizData.page, total: data.bizData.records});
				}else {
					layer.msg('查询数据出错',{icon:5,time:2000});
					$("#tableInfo").datagrid("loaded");
				}
			},
			error : function(err) {
				layer.msg('查询数据出错',{icon:5,time:2000});
				$("#tableInfo").datagrid("loaded");
			}
		});
	}

</script>
</body>
</html>